<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="../css/top.css" rel="stylesheet" />

</head>
<body>

<nav class="navbar navbar-inverse" role="navigation">
    <div class="container-fluid">
        <div class="collapse navbar-collapse" id="example-navbar-collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a  href='#' ><span class="glyphicon glyphicon-user" id="userNickName"></span> </a></li>
                <li><a  href='#' id="logout" ><span class="glyphicon glyphicon-log-in" ></span> 注销</a></li>
            </ul>
        </div>
    </div>
</nav>
<input type="hidden" id="isLogIn">
</body>

<script src="../js/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {

        let userIdExit = document.cookie.indexOf("userid");
        if (userIdExit == -1)
        {
            $('#userNickName').html("未登录");
            $("#isLogIn").val("0");
        }else{
            let id = $.cookie('userid');
            $("#isLogIn").val("1");
            jQuery.post("/getUserInfoById", {"userId": id}, function (rst){
                $("#userNickName").html(rst.userNickname);
            })
        }
        jQuery("#logout").click(function () {
            $.removeCookie('usreid',{path: '/'});
            $.removeCookie('username',{path: '/'});
            alert("注销成功");
            $("#isLogIn").val("0");
            $('#userNickName').html("未登录");
            // window.parent.location.replace("usersSign.html");
        })

        jQuery("#userNickName").click(function () {
            let isLogIN = $("#isLogIn").val();
            if (isLogIN == "0"){
                window.parent.location.replace("usersSign.html");
            }
        })

    })
</script>
</html>

